package com.fei;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.autoconfigure.AutoConfiguration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;


/**
 * @ Package com.fei.config
 * @ Author  费小钢
 * @ Date 2025/8/12 7:03
 * @ Description: knife4j文档配置
 * @ Version v1.0
 * @ Copyright @2025-2027 云图一然
 **/
@AutoConfiguration
@ConditionalOnClass(EnableKnife4j.class)
public class OpenApiConfig {

    /**
     * 配置OpenAPI基本信息
     */
    @Bean
    @ConditionalOnMissingBean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("鉴权中心")
                        .version("1.0")
                        .description("Auth鉴权中心文档")
                        .contact(new Contact()
                                .name("费小刚")
                                .email("fxiaogang@163.com")
                                .url("https://fei.com"))
                        .license(new License()
                                .name("Apache 2.0")
                                .url("https://www.apache.org/licenses/LICENSE-2.0")));
    }

    /**
     * 分组1：默认分组（所有接口）
     */
    @Bean
    @ConditionalOnMissingBean
    public GroupedOpenApi defaultApi() {
        return GroupedOpenApi.builder()
                .group("默认分组")
                .pathsToMatch("/**")
                .build();
    }
}
